package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.vo.req.order.OrderStrikeRequestVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.DataScreeningPersonnelControl;
import com.ruoyi.system.service.IDataScreeningPersonnelControlService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 管控情况Controller
 * 
 * @author ruoyi
 * @date 2024-06-25
 */
@RestController
@RequestMapping("/control")
public class DataScreeningPersonnelControlController extends BaseController
{
    @Autowired
    private IDataScreeningPersonnelControlService dataScreeningPersonnelControlService;

    /**
     * 查询管控情况列表
     */
    @RequiresPermissions("system:control:list")
    @GetMapping("/list")
    public TableDataInfo list(DataScreeningPersonnelControl dataScreeningPersonnelControl)
    {
        startPage();
        List<DataScreeningPersonnelControl> list = dataScreeningPersonnelControlService.selectDataScreeningPersonnelControlList(dataScreeningPersonnelControl);
        return getDataTable(list);
    }

    /**
     * 导出管控情况列表
     */
    @RequiresPermissions("system:control:export")
    @Log(title = "管控情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataScreeningPersonnelControl dataScreeningPersonnelControl)
    {
        List<DataScreeningPersonnelControl> list = dataScreeningPersonnelControlService.selectDataScreeningPersonnelControlList(dataScreeningPersonnelControl);
        ExcelUtil<DataScreeningPersonnelControl> util = new ExcelUtil<DataScreeningPersonnelControl>(DataScreeningPersonnelControl.class);
        util.exportExcel(response, list, "管控情况数据");
    }

    /**
     * 获取管控情况详细信息
     */
    @RequiresPermissions("system:control:query")
    @GetMapping(value = "/{controlId}")
    public AjaxResult getInfo(@PathVariable("controlId") Long controlId)
    {
        return AjaxResult.success(dataScreeningPersonnelControlService.selectDataScreeningPersonnelControlByControlId(controlId));
    }

    /**
     * 新增管控情况
     */
    @RequiresPermissions("system:control:add")
    @Log(title = "管控情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataScreeningPersonnelControl dataScreeningPersonnelControl)
    {
        return toAjax(dataScreeningPersonnelControlService.insertDataScreeningPersonnelControl(dataScreeningPersonnelControl));
    }

    /**
     * 修改管控情况
     */
    @RequiresPermissions("system:control:edit")
    @Log(title = "管控情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataScreeningPersonnelControl dataScreeningPersonnelControl)
    {
        return toAjax(dataScreeningPersonnelControlService.updateDataScreeningPersonnelControl(dataScreeningPersonnelControl));
    }

    /**
     * 删除管控情况
     */
    @RequiresPermissions("system:control:remove")
    @Log(title = "管控情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{controlIds}")
    public AjaxResult remove(@PathVariable Long[] controlIds)
    {
        return toAjax(dataScreeningPersonnelControlService.deleteDataScreeningPersonnelControlByControlIds(controlIds));
    }





//    @ApiOperation("将核查信息导入管控")
//    @PostMapping("/exportgk")
//    public R exportGK(@RequestBody OrderStrikeRequestVO req) {
//        return R.ok(dataScreeningPersonnelControlService.exportGK(req));
//    }
}
